package com.lanou3g.hw0518.controller;

import com.lanou3g.hw0518.model.RegisterModel;
import com.lanou3g.hw0518.pojo.User;
import com.lanou3g.hw0518.util.JDBCUtil;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/5/21;
 * Otherwise, I don't know who created it either
 */

public class RegisterController {
    private RegisterModel model = new RegisterModel();

    public boolean register(User user){
        JDBCUtil.begin();// 开启事务
        if (!model.hasThisName(user.getUsername())){
            JDBCUtil.closeConn();// 关闭连接
            return model.register(user);
        }
        JDBCUtil.closeConn();// 关闭连接
        return false;
    }
}
